<template>
	<view class="container">
		<view class="top"></view>
		<view class="logo"><image src="../../static/img/hzs.png"></image></view>
		<view class="hzs"><text>合作社</text></view>
		<view class="f-menu">
			<view @click="goto(item.url,item.vip)" class="item" v-for="(item,index) in list" :key="index">
				<image :src="item.icon" class="picture" mode=""></image>
				<view class="title">
					{{item.name}}
				</view>
				<view class="explain">
					{{item.explain}}
				</view>
			</view>
		</view>
			
			<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[{
					id:1,
					icon:this.$mAssetsPath.zhhd,
					name:"智汇活动",
					explain:"我们一起参加活动",
					url:this.$mRoutesConfig.zhhd,
					vip:0
				},{
					id:2,
					icon:this.$mAssetsPath.zhtd,
					name:"智汇团队",
					explain:"寻找合适的伙伴合作",
					url:this.$mRoutesConfig.zhtd,
					vip:1
				},{
					id:3,
					icon:this.$mAssetsPath.zhfw,
					name:"智汇服务",
					explain:"我需要异地服务合作",
					url:this.$mRoutesConfig.zhfw,
					vip:1
				},{
					id:4,
					icon:this.$mAssetsPath.zhnjy,
					name:"智汇N+1",
					explain:"我们互相认可 共同创造辉煌",
					url:this.$mRoutesConfig.zhnjy,
					vip:2
				},
				{
					id:5,
					icon:this.$mAssetsPath.zhgs,
					name:"智汇公社",
					explain:"我们成立公社 拓展合作圈子",
					url:this.$mRoutesConfig.zhgs,
					vip:1
				},
				// {
				// 	id:2,
				// 	icon:this.$mAssetsPath.zhfx,
				// 	name:"智汇分享",
				// 	explain:"分享让我们的 记忆更加深刻",
				// 	url:this.$mRoutesConfig.login
				// },{
				// 	id:3,
				// 	icon:this.$mAssetsPath.zhhb,
				// 	name:"智汇红包",
				// 	explain:"又多了一个记 住你的途径",
				// 	url:this.$mRoutesConfig.zhhb
				// },
				
				{
					id:4,
					icon:this.$mAssetsPath.zhdn,
					name:"智汇大脑",
					explain:"我们一起学习 定制学习生活",
					url:this.$mRoutesConfig.zhxx
				}],	
				profileStatus:'',
			}
		},
		onLoad(){
		},
		onShow(){
			this.getfetchUserReviewed();
		// #ifdef APP-PLUS
			this.$tabbarView.$watch();
			// #endif
		},
		onHide() {
			// #ifdef APP-PLUS
			this.$tabbarView.$watch();
			// #endif
		},
		methods: {
			async getfetchUserReviewed(){
				if(uni.getStorageSync('token')){
				let result = await this.$apis.fetchUserReviewed();
				this.profileStatus = result.data;			
				}
			},
			goto(url,vip){
				if(uni.getStorageSync('token')){
					console.log("profileStatus",this.profileStatus);
					var that = this;
					if(this.profileStatus == 1){
						if(url != ''){		
							if(this.$store.state.userInfo.vipLevel < 1 && vip == 1) {
								this.$refs.uToast.show({
									title: '会员专享，请升级',
									type: 'warning',
								})
								return;
							}else if(this.$store.state.userInfo.vipLevel < 2 && vip == 2) {
								this.$refs.uToast.show({
									title: '高级VIP专享，请升级',
									type: 'warning',
								})
								return;
							}else{
								this.$mRouter.push({
									route: url
								});
							}
						}else{
							this.$refs.uToast.show({
								title: '404，请联系客服',
								type: 'success',
							})
						}
					}else if(this.profileStatus == 2){
						uni.showModal({
							title:"提示",
							content:"资料审核中，通过以后才可以操作",
							success(res) {
								if(res.confirm){
									
								}
							}
						})
					}else{
						uni.showModal({
							title:"提示",
							content:"请先完善资料",
							confirmText:"立即完善",
							success(res) {
								if(res.confirm){
									if(that.$store.state.userInfo.identityType==1){	
										uni.navigateTo({
											url: '../user/myCompanyPage'
										});
									}else{
										uni.navigateTo({
											url: '../user/myHomePage'
										});
									}
								}
							}
						})
					}
				}else{
					uni.navigateTo({
						url: '../login/login'
					});
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	page {background-color: #fff;}
	.top {
		height: 80rpx;
		width: 100%;
	}
	.logo {width:166rpx;height:153rpx;margin:0 auto;
		image {width:100%;height:100%;}
	}
	.hzs {
		width:100%;
		margin:50rpx 0;
		height:80rpx;
		position: relative;
		text-align: center;
		&::before {
			content:'';
			position: absolute;
			left:0;
			top:50%;
			width:100%;
			height: 1rpx;
			border-bottom: 1px solid #E9E9E9;
		}
		text {			
			position: absolute;
			width:30%;
			left:35%;
			z-index:1;
			font-size: 46rpx;
			color: #0D1D36;
			padding:10rpx 20rpx;
			text-align: center;
			background-color: #fff;
		}
	}
	.f-menu {display: flex;flex-flow: wrap;padding:0 30rpx;padding-top:100rpx;justify-content: flex-start;
		.item {width:33%;margin-bottom:50rpx;text-align: center;
			.title {
				padding:24rpx 0;
				font-weight: 700;
				font-size: 34rpx;
				color: #0D1D36;
			}
			.explain {
				margin: 0 auto;
				width:80%;
				color: #888D99;
			}
			image {
				width: 110rpx;
				height: 110rpx;
			}
		}
	}
	
</style>
